﻿#pragma once
#include "data_structure.h"
#include "facility.h"
#include "file.h"
#include "facility_manager.h"
void init_system(System* system);
void test01() {
    System system;
    init_system(&system);
    init_FList(&system.facility_link);
    read_facility_file(&system, "..\\src\\facility.txt");
    FNode* temp = system.facility_link.head->next;
    for (int i = 0; i < system.facility_link.num; i++) {
        Facility facility = temp->facility;
        printf("%d,%s,%d,%d,%d,%s,%.2f\n",
            facility.id,
            facility.name,
            facility.manager_id,
            facility.type,
            facility.area,
            facility.open_time,
            facility.price_per_half_hour);
        temp = temp->next;
    }
    Facility facility = create_facility(system, 4001, (char*)"台球场", -1, BILLIARDS_COUNT, 100, (char*)"08:00-22:00", 7,2);
    add_facility(&system.facility_link, &facility);
    write_facility_file(system, "..\\src\\facility.txt");
    print_facilities(&system.facility_link);
}
void test02() {
    System system;
    init_system(&system);
    init_FList(&system.facility_link);
    read_facility_file(&system, "..\\src\\facility.txt");
    print_facilities(&system.facility_link);
    init_FMList(&system.facility_manager_link);
    read_facility_manager_file(&system, "..\\src\\facility_manager.txt");
    print_facility_managers(&system.facility_manager_link);
    Facility* facilities[MAX_FACILITIES];
    facilities[0] = find_facility(&system.facility_link, 4001);
    facilities[1] = find_facility(&system.facility_link, 4002);
    FacilityManager facility_manager = create_facility_manager(103, "小程", 2,facilities, "承宇", "233333", 110);
    add_facility_manager(&system.facility_manager_link, &facility_manager);
    write_facility_manager_file(system, "..\\facility_manager.txt");
    print_facility_managers(&system.facility_manager_link);
}
void test03() {
    System system;
    init_system(&system);
    init_FList(&system.facility_link);
    read_facility_file(&system, "..\\src\\facility.txt");
    for (int i = 0; i < system.facility_link.num; i++) {
        FNode* cur = system.facility_link.head->next;
        TNode* t_cur = cur->facility.time_list.head->next;
        for (int j = 0; j < cur->facility.time_list.num; j++) {
            printf("%d年%d月%d日\n", t_cur->t.year, t_cur->t.month, t_cur->t.day);
            for (int k = 0; k < 28; k++) {
                printf("%d ", t_cur->t.day_time[k]);
            }
            printf("\n");
            t_cur = t_cur->next;
        }
    }
}